package com.health.viewscontrols.tijian;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import com.health.viewscontrols.NovaActivity;
import com.health.viewscontrols.NovaApplication;
import com.health.R;
import com.health.adapter.CheckBoxAdapter;
import com.health.db.FDbManager;
import com.health.tablebean.ARCHIVE_MEDI_PHYS_DIST;
import com.health.tablebean.BD_DD_INFO;
import com.health.tablebean.OLD_MEDICINE_CN;
import com.health.tablebean.OLD_MEDICINE_RESULT;
import com.health.tools.CalendarView;
import com.health.tools.GlobalConts;
import com.health.view.spinner.NiceSpinner;
import com.health.widget.EditTextWithDate;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.GridView;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

/**
 * 中医体质问卷
 * 
 * @author nova 老年人
 */
public class ZYTZ_WenJuanActivity extends NovaActivity {
	private TextView testTile;// 题目标题
	private Button button_select1;// 按钮1
	private Button button_select2;// 按钮2
	private Button button_select3;// 按钮3
	private Button button_select4;// 按钮4
	private Button button_select5;// 按钮5
	private CalendarView calendar;
	int count = 0;
	int testScore[] = new int[33];
	// ImageView calendar_img;
	Date date;
	public static ZYTZ_WenJuanActivity zytz_WenJuanActivity;
	private RelativeLayout wentiLayout;// 问题布局
	private RelativeLayout resultLayout;// 结果布局
	// private MyGridView myGridView_qixuzhi;// 气虚质checkbox
	// private MyGridView myGridView_yangxuzhi;// 阳虚质checkbox
	// private MyGridView myGridView_yinxuzhi;// 阴虚质checkbox
	// private MyGridView myGridView_tanshizhi;// 痰湿质checkbox
	// private MyGridView myGridView_shirezhi;// 湿热质checkbox
	// private MyGridView myGridView_xueyuzhi;// 血瘀质checkbox
	// private MyGridView myGridView_qiyuzhi;// 气郁质checkbox
	// private MyGridView myGridView_tebingzhi;// 特禀质checkbox
	// private MyGridView myGridView_pinghezhi;// 平和质checkbox

	private GridView myGridView_qixuzhi;// 气虚质checkbox
	private GridView myGridView_yangxuzhi;// 阳虚质checkbox
	private GridView myGridView_yinxuzhi;// 阴虚质checkbox
	private GridView myGridView_tanshizhi;// 痰湿质checkbox
	private GridView myGridView_shirezhi;// 湿热质checkbox
	private GridView myGridView_xueyuzhi;// 血瘀质checkbox
	private GridView myGridView_qiyuzhi;// 气郁质checkbox
	private GridView myGridView_tebingzhi;// 特禀质checkbox
	private GridView myGridView_pinghezhi;// 平和质checkbox
	private HashMap<Integer, BD_DD_INFO> dbMap;
	private List<BD_DD_INFO> dbList;
	// 得分
	TextView qixuzhi_score;
	int qixuzhi_score_string;
	TextView yangxuzhi_score;
	int yangxuzhi_score_string;
	TextView yinxuzhi_score;
	int yinxuzhi_score_string;
	TextView tanshizhi_score;
	int tanshizhi_score_string;
	TextView shirezhi_score;
	int shirezhi_score_string;
	TextView xueyuzhi_score;
	int xueyuzhi_score_string;
	TextView qiyuzhi_score;
	int qiyuzhi_score_string;
	TextView tebingzhi_score;
	int tebingzhi_score_string;
	TextView pinghezhi_score;
	int pinghezhi_score_string;
	// CheckBoxAdapter
	private CheckBoxAdapter checkBoxAdapter_qixuzhi;
	private CheckBoxAdapter checkBoxAdapter_yangxuzhi;
	private CheckBoxAdapter checkBoxAdapter_yinxuzhi;
	private CheckBoxAdapter checkBoxAdapter_tanshizhi;
	private CheckBoxAdapter checkBoxAdapter_shirezhi;
	private CheckBoxAdapter checkBoxAdapter_xueyuzhi;
	private CheckBoxAdapter checkBoxAdapter_qiyuzhi;
	private CheckBoxAdapter checkBoxAdapter_tebingzhi;
	private CheckBoxAdapter checkBoxAdapter_pinghezhi;

	// result radioButton;
	RadioButton result_qixuzhi_1;
	RadioButton result_qixuzhi_2;
	RadioButton result_yangxuzhi_1;
	RadioButton result_yangxuzhi_2;
	RadioButton result_yinxuzhi_1;
	RadioButton result_yinxuzhi_2;
	RadioButton result_tanshizhi_1;
	RadioButton result_tanshizhi_2;
	RadioButton result_shirezhi_1;
	RadioButton result_shirezhi_2;
	RadioButton result_xueyuzhi_1;
	RadioButton result_xueyuzhi_2;
	RadioButton result_qiyuzhi_1;
	RadioButton result_qiyuzhi_2;
	RadioButton result_tebingzhi_1;
	RadioButton result_tebingzhi_2;
	RadioButton result_pinghezhi_1;
	RadioButton result_pinghezhi_2;
	// 时间，负责人
	EditTextWithDate dateText;
	NiceSpinner personText;
	Button save_result;// 保存结果
	String IDCARD;// 身份证号
	// 数据库
	OLD_MEDICINE_RESULT old_MEDICINE_RESULT;
	ARCHIVE_MEDI_PHYS_DIST archive_MEDI_PHYS_DIST;
	FDbManager fdDbManager;
	// 中医保健知道edit
	// EditText qixuzhi_edit;
	// EditText yangxuzhi_edit;
	// EditText yinxuzhi_edit;
	// EditText tanshizhi_edit;
	// EditText shirezhi_edit;
	// EditText xueyuzhi_edit;
	// EditText qiyuzhi_edit;
	// EditText tebingzhi_edit;
	// EditText pinghezhi_edit;
	OLD_MEDICINE_CN old_MEDICINE_CN;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_zyti_wenjuan);
		zytz_WenJuanActivity = this;
		old_MEDICINE_RESULT = new OLD_MEDICINE_RESULT();
		archive_MEDI_PHYS_DIST = new ARCHIVE_MEDI_PHYS_DIST();
		old_MEDICINE_CN = new OLD_MEDICINE_CN();
		date = new Date();
		// if (AlertHelper.calendar == null) {
		// calendar = new CalendarView(ZYTZ_WenJuanActivity.this);
		// } else {
		// calendar = AlertHelper.calendar;
		// calendar.setCurdate(date);
		// }
		fdDbManager = FDbManager.getInstance(zytz_WenJuanActivity);
		findViews();
		setListeners();
		getData();
		// getDate(date);
	}

	public void sendEdit() {
	}

	// public void getDate(Date downDate) {
	// date = downDate;
	// // 获取日历中年月 ya[0]为年，ya[1]为月（格式大家可以自行在日历控件中改）
	// String[] ya = calendar.getYearMonthAndDay(date).split("-");
	// String dateString = ya[0] + "年" + ya[1] + "月" + ya[2] + "日";
	// dateText.setText(ya[0] + "年" + ya[1] + "月" + ya[2] + "日");
	//
	// }

	@Override
	public void findViews() {
		// 题目
		testTile = (TextView) findViewById(R.id.type1_title);
		button_select1 = (Button) findViewById(R.id.type1_button1);
		button_select2 = (Button) findViewById(R.id.type1_button2);
		button_select3 = (Button) findViewById(R.id.type1_button3);
		button_select4 = (Button) findViewById(R.id.type1_button4);
		button_select5 = (Button) findViewById(R.id.type1_button5);
		// 布局
		wentiLayout = (RelativeLayout) findViewById(R.id.type1_layout);
		resultLayout = (RelativeLayout) findViewById(R.id.result);
		// MyGridView
		myGridView_qixuzhi =(GridView)findViewById(R.id.qixuzhi_gridview);
		myGridView_yangxuzhi = (GridView) findViewById(R.id.yangxuzhi_gridview);
		myGridView_yinxuzhi =(GridView)findViewById(R.id.yinxuzhi_gridview);
		myGridView_tanshizhi =(GridView)findViewById(R.id.tanshizhi_gridview);
		myGridView_shirezhi =(GridView)findViewById(R.id.shirezhi_gridview);
		myGridView_xueyuzhi =(GridView)findViewById(R.id.xueyuzhi_gridview);
		myGridView_qiyuzhi =(GridView)findViewById(R.id.qiyuzhi_gridview);
		myGridView_tebingzhi =(GridView)findViewById(R.id.tebingzhi_gridview);
		myGridView_pinghezhi =(GridView)findViewById(R.id.pinghezhi_gridview);
		// 得分
		qixuzhi_score = (TextView) findViewById(R.id.qixuzhi_score_edit);
		yangxuzhi_score = (TextView) findViewById(R.id.yangxuzhi_score_edit);
		yinxuzhi_score = (TextView) findViewById(R.id.yinxuzhi_score_edit);
		tanshizhi_score = (TextView) findViewById(R.id.tanshizhi_score_edit);
		shirezhi_score = (TextView) findViewById(R.id.shirezhi_score_edit);
		xueyuzhi_score = (TextView) findViewById(R.id.xueyuzhi_score_edit);
		qiyuzhi_score = (TextView) findViewById(R.id.qiyuzhi_score_edit);
		tebingzhi_score = (TextView) findViewById(R.id.tebingzhi_score_edit);
		pinghezhi_score = (TextView) findViewById(R.id.pinghezhi_score_edit);
		// result RadioButton
		result_qixuzhi_1 = (RadioButton) findViewById(R.id.qixuzhi_1);
		result_qixuzhi_2 = (RadioButton) findViewById(R.id.qixuzhi_2);
		result_yangxuzhi_1 = (RadioButton) findViewById(R.id.yangxuzhi_1);
		result_yangxuzhi_2 = (RadioButton) findViewById(R.id.yangxuzhi_2);
		result_yinxuzhi_1 = (RadioButton) findViewById(R.id.yinxuzhi_1);
		result_yinxuzhi_2 = (RadioButton) findViewById(R.id.yinxuzhi_2);
		result_tanshizhi_1 = (RadioButton) findViewById(R.id.tanshizhi_1);
		result_tanshizhi_2 = (RadioButton) findViewById(R.id.tanshizhi_2);
		result_shirezhi_1 = (RadioButton) findViewById(R.id.shirezhi_1);
		result_shirezhi_2 = (RadioButton) findViewById(R.id.shirezhi_2);
		result_xueyuzhi_1 = (RadioButton) findViewById(R.id.xueyuzhi_1);
		result_xueyuzhi_2 = (RadioButton) findViewById(R.id.xueyuzhi_2);
		result_qiyuzhi_1 = (RadioButton) findViewById(R.id.qiyuzhi_1);
		result_qiyuzhi_2 = (RadioButton) findViewById(R.id.qiyuzhi_2);
		result_tebingzhi_1 = (RadioButton) findViewById(R.id.tebingzhi_1);
		result_tebingzhi_2 = (RadioButton) findViewById(R.id.tebingzhi_2);
		result_pinghezhi_1 = (RadioButton) findViewById(R.id.pinghezhi_1);
		result_pinghezhi_2 = (RadioButton) findViewById(R.id.pinghezhi_2);
		// calendar_img
		// calendar_img = (ImageView) findViewById(R.id.calendar_img);
		dateText = (EditTextWithDate) findViewById(R.id.date_edit);
		personText = (NiceSpinner) findViewById(R.id.person_edit);
		save_result = (Button) findViewById(R.id.save_result);
		// 中医保健指导edit
		// qixuzhi_edit = (EditText) findViewById(R.id.qixuzhi_qita_edit);
		// yangxuzhi_edit = (EditText) findViewById(R.id.yangxuzhi_qita_edit);
		// yinxuzhi_edit = (EditText) findViewById(R.id.yinxuzhi_qita_edit);
		// tanshizhi_edit = (EditText) findViewById(R.id.tanshizhi_qita_edit);
		// shirezhi_edit = (EditText) findViewById(R.id.shirezhi_qita_edit);
		// xueyuzhi_edit = (EditText) findViewById(R.id.xueyuzhi_qita_edit);
		// qiyuzhi_edit = (EditText) findViewById(R.id.qiyuzhi_qita_edit);
		// tebingzhi_edit = (EditText) findViewById(R.id.tebingzhi_qita_edit);
		// pinghezhi_edit = (EditText) findViewById(R.id.pinghezhi_qita_edit);

		dateText.setBefore(new Date());

	}

	public void getData() {
		dbMap = new HashMap<Integer, BD_DD_INFO>();
		dbList = new ArrayList<BD_DD_INFO>();
		List<BD_DD_INFO> minzuList = FDbManager.getInstance(this).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM100-55_6'");
		for (BD_DD_INFO info : minzuList) {
			System.out.println(info.getDATAINFO());
			dbMap.put(Integer.parseInt(info.getSORT()), info);
		}
		BD_DD_INFO info1 = new BD_DD_INFO();
		info1.setSORT("6");
		info1.setDATAINFO("6.其他");
		dbMap.put(Integer.parseInt(info1.getSORT()), info1);
		for (int i = 0; i < dbMap.size(); i++) {
			dbList.add(dbMap.get(i + 1));
		}
		// checkBoxAdapter_qixuzhi = new CheckBoxAdapter(this,
		// dbList,qixuzhi_edit);
		// checkBoxAdapter_yangxuzhi = new CheckBoxAdapter(this,
		// dbList,yangxuzhi_edit);
		// checkBoxAdapter_yinxuzhi = new CheckBoxAdapter(this,
		// dbList,yinxuzhi_edit);
		// checkBoxAdapter_tanshizhi = new CheckBoxAdapter(this,
		// dbList,tanshizhi_edit);
		// checkBoxAdapter_shirezhi = new CheckBoxAdapter(this,
		// dbList,shirezhi_edit);
		// checkBoxAdapter_xueyuzhi = new CheckBoxAdapter(this,
		// dbList,xueyuzhi_edit);
		// checkBoxAdapter_qiyuzhi = new CheckBoxAdapter(this,
		// dbList,qiyuzhi_edit);
		// checkBoxAdapter_tebingzhi = new CheckBoxAdapter(this,
		// dbList,tebingzhi_edit);
		// checkBoxAdapter_pinghezhi = new CheckBoxAdapter(this,
		// dbList,pinghezhi_edit);
		checkBoxAdapter_qixuzhi = new CheckBoxAdapter(this, dbList);
		checkBoxAdapter_yangxuzhi = new CheckBoxAdapter(this, dbList);
		checkBoxAdapter_yinxuzhi = new CheckBoxAdapter(this, dbList);
		checkBoxAdapter_tanshizhi = new CheckBoxAdapter(this, dbList);
		checkBoxAdapter_shirezhi = new CheckBoxAdapter(this, dbList);
		checkBoxAdapter_xueyuzhi = new CheckBoxAdapter(this, dbList);
		checkBoxAdapter_qiyuzhi = new CheckBoxAdapter(this, dbList);
		checkBoxAdapter_tebingzhi = new CheckBoxAdapter(this, dbList);
		checkBoxAdapter_pinghezhi = new CheckBoxAdapter(this, dbList);

		myGridView_qixuzhi.setAdapter(checkBoxAdapter_qixuzhi);
		myGridView_yangxuzhi.setAdapter(checkBoxAdapter_yangxuzhi);
		myGridView_yinxuzhi.setAdapter(checkBoxAdapter_yinxuzhi);
		myGridView_tanshizhi.setAdapter(checkBoxAdapter_tanshizhi);
		myGridView_shirezhi.setAdapter(checkBoxAdapter_shirezhi);
		myGridView_xueyuzhi.setAdapter(checkBoxAdapter_xueyuzhi);
		myGridView_qiyuzhi.setAdapter(checkBoxAdapter_qiyuzhi);
		myGridView_tebingzhi.setAdapter(checkBoxAdapter_tebingzhi);
		myGridView_pinghezhi.setAdapter(checkBoxAdapter_pinghezhi);

		// 获取医生编号
		GlobalConts.doctorList(personText);
		IDCARD = NovaApplication.getUserInfo().getIDCARD();
	}

	@Override
	public void setListeners() {
		// // 弹出日历
		// calendar_img.setOnClickListener(new OnClickListener() {
		//
		// @Override
		// public void onClick(View v) {
		// AlertHelper.showYearAndMonth(ZYTZ_WenJuanActivity.this, new Date());
		//
		// }
		// });
		button_select1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (count == 0) {
					testScore[0] = 1;
					testTile.setText(R.string.zhongyitizhi_test2);
					old_MEDICINE_CN.setENERGY("1");
					count++;
				} else if (count == 1) {
					testScore[1] = 1;
					testTile.setText(R.string.zhongyitizhi_test3);
					old_MEDICINE_CN.setTIRED("1");
					count++;
				} else if (count == 2) {
					testScore[2] = 1;
					testTile.setText(R.string.zhongyitizhi_test4);
					old_MEDICINE_CN.setBREATH("1");
					count++;
				} else if (count == 3) {
					testScore[3] = 1;
					testTile.setText(R.string.zhongyitizhi_test5);
					old_MEDICINE_CN.setVOICE("1");
					count++;
				} else if (count == 4) {
					testScore[4] = 1;
					testTile.setText(R.string.zhongyitizhi_test6);
					old_MEDICINE_CN.setEMOTION("1");
					count++;
				} else if (count == 5) {
					testScore[5] = 1;
					testTile.setText(R.string.zhongyitizhi_test7);
					old_MEDICINE_CN.setSPIRIT("1");
					count++;
				} else if (count == 6) {
					testScore[6] = 1;
					testTile.setText(R.string.zhongyitizhi_test8);
					old_MEDICINE_CN.setALONE("1");
					count++;
				} else if (count == 7) {
					testScore[7] = 1;
					testTile.setText(R.string.zhongyitizhi_test9);
					button_select1.setText(R.string.type2_button1);
					button_select2.setText(R.string.type2_button2);
					button_select3.setText(R.string.type2_button3);
					button_select4.setText(R.string.type2_button4);
					button_select5.setText(R.string.type2_button5);
					old_MEDICINE_CN.setFEAR("1");
					count++;
				} else if (count == 8) {
					testScore[8] = 1;
					testTile.setText(R.string.zhongyitizhi_test10);
					old_MEDICINE_CN.setWEIGHT("1");
					type1();
					count++;
				} else if (count == 9) {
					testScore[9] = 1;
					testTile.setText(R.string.zhongyitizhi_test11);
					old_MEDICINE_CN.setEYE("1");
					count++;
				} else if (count == 10) {
					testScore[10] = 1;
					testTile.setText(R.string.zhongyitizhi_test12);
					old_MEDICINE_CN.setFOOTHAND("1");
					count++;
				} else if (count == 11) {
					testScore[11] = 1;
					testTile.setText(R.string.zhongyitizhi_test13);
					old_MEDICINE_CN.setSTOMACH("1");
					count++;
				} else if (count == 12) {
					testScore[12] = 1;
					testTile.setText(R.string.zhongyitizhi_test14);
					button_select1.setText(R.string.type3_button1);
					button_select2.setText(R.string.type3_button2);
					button_select3.setText(R.string.type3_button3);
					button_select4.setText(R.string.type3_button4);
					button_select5.setText(R.string.type3_button5);
					old_MEDICINE_CN.setCOLD("1");
					count++;
				} else if (count == 13) {
					testScore[13] = 1;
					testTile.setText(R.string.zhongyitizhi_test15);
					old_MEDICINE_CN.setINFLUENZA("1");
					type1();
					count++;
				} else if (count == 14) {
					testScore[14] = 1;
					testTile.setText(R.string.zhongyitizhi_test16);
					old_MEDICINE_CN.setNASAL("1");
					count++;
				} else if (count == 15) {
					testScore[15] = 1;
					testTile.setText(R.string.zhongyitizhi_test17);
					button_select1.setText(R.string.type4_button1);
					button_select2.setText(R.string.type4_button2);
					button_select3.setText(R.string.type4_button3);
					button_select4.setText(R.string.type4_button4);
					button_select5.setText(R.string.type4_button5);
					old_MEDICINE_CN.setSNORE("1");
					count++;
				} else if (count == 16) {
					testScore[16] = 1;
					testTile.setText(R.string.zhongyitizhi_test18);
					old_MEDICINE_CN.setALLERGY("1");
					type1();
					count++;
				} else if (count == 17) {
					testScore[17] = 1;
					testTile.setText(R.string.zhongyitizhi_test19);
					old_MEDICINE_CN.setURTICARIA("1");
					count++;
				} else if (count == 18) {
					testScore[18] = 1;
					testTile.setText(R.string.zhongyitizhi_test20);
					old_MEDICINE_CN.setSKIN("1");
					count++;
				} else if (count == 19) {
					testScore[19] = 1;
					testTile.setText(R.string.zhongyitizhi_test21);
					old_MEDICINE_CN.setSCRATCH("1");
					count++;
				} else if (count == 20) {
					testScore[20] = 1;
					testTile.setText(R.string.zhongyitizhi_test22);
					old_MEDICINE_CN.setMOUTH("1");
					count++;
				} else if (count == 21) {
					testScore[21] = 1;
					testTile.setText(R.string.zhongyitizhi_test23);
					old_MEDICINE_CN.setARMS("1");
					count++;
				} else if (count == 22) {
					testScore[22] = 1;
					testTile.setText(R.string.zhongyitizhi_test24);
					old_MEDICINE_CN.setGREASY("1");
					count++;
				} else if (count == 23) {
					testScore[23] = 1;
					testTile.setText(R.string.zhongyitizhi_test25);
					old_MEDICINE_CN.setSPOT("1");
					count++;
				} else if (count == 24) {
					testScore[24] = 1;
					testTile.setText(R.string.zhongyitizhi_test26);
					old_MEDICINE_CN.setECZEMA("1");
					count++;
				} else if (count == 25) {
					testScore[25] = 1;
					testTile.setText(R.string.zhongyitizhi_test27);
					old_MEDICINE_CN.setTHIRSTY("1");
					count++;
				} else if (count == 26) {
					testScore[26] = 1;
					testTile.setText(R.string.zhongyitizhi_test28);
					button_select1.setText(R.string.type5_button1);
					button_select2.setText(R.string.type5_button2);
					button_select3.setText(R.string.type5_button3);
					button_select4.setText(R.string.type5_button4);
					button_select5.setText(R.string.type5_button5);
					old_MEDICINE_CN.setSMELL("1");
					count++;
				} else if (count == 27) {
					testScore[27] = 1;
					testTile.setText(R.string.zhongyitizhi_test29);
					old_MEDICINE_CN.setADBOMEN("1");
					type1();
					count++;
				} else if (count == 28) {
					testScore[28] = 1;
					testTile.setText(R.string.zhongyitizhi_test30);
					old_MEDICINE_CN.setCOOLFOOD("1");
					count++;
				} else if (count == 29) {
					testScore[29] = 1;
					testTile.setText(R.string.zhongyitizhi_test31);
					old_MEDICINE_CN.setDEFECATE("1");
					count++;
				} else if (count == 30) {
					testScore[30] = 1;
					testTile.setText(R.string.zhongyitizhi_test32);
					old_MEDICINE_CN.setDEFECATEDRY("1");
					count++;
				} else if (count == 31) {
					testScore[31] = 1;
					testTile.setText(R.string.zhongyitizhi_test33);
					old_MEDICINE_CN.setTONGUE("1");
					count++;
				} else if (count == 32) {
					testScore[32] = 1;
					old_MEDICINE_CN.setVEIN("1");
					getTestScore();
					count++;
				} else {

				}

			}
		});
		button_select2.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (count == 0) {
					testScore[0] = 2;
					testTile.setText(R.string.zhongyitizhi_test2);
					old_MEDICINE_CN.setENERGY("2");
					count++;
				} else if (count == 1) {
					testScore[1] = 2;
					testTile.setText(R.string.zhongyitizhi_test3);
					old_MEDICINE_CN.setTIRED("2");
					count++;
				} else if (count == 2) {
					testScore[2] = 2;
					testTile.setText(R.string.zhongyitizhi_test4);
					old_MEDICINE_CN.setBREATH("2");
					count++;
				} else if (count == 3) {
					testScore[3] = 2;
					testTile.setText(R.string.zhongyitizhi_test5);
					old_MEDICINE_CN.setVOICE("2");
					count++;
				} else if (count == 4) {
					testScore[4] = 2;
					testTile.setText(R.string.zhongyitizhi_test6);
					old_MEDICINE_CN.setEMOTION("2");
					count++;
				} else if (count == 5) {
					testScore[5] = 2;
					testTile.setText(R.string.zhongyitizhi_test7);
					old_MEDICINE_CN.setSPIRIT("2");
					count++;
				} else if (count == 6) {
					testScore[6] = 2;
					testTile.setText(R.string.zhongyitizhi_test8);
					old_MEDICINE_CN.setALONE("2");
					count++;
				} else if (count == 7) {
					testScore[7] = 2;
					testTile.setText(R.string.zhongyitizhi_test9);
					button_select1.setText(R.string.type2_button1);
					button_select2.setText(R.string.type2_button2);
					button_select3.setText(R.string.type2_button3);
					button_select4.setText(R.string.type2_button4);
					button_select5.setText(R.string.type2_button5);
					old_MEDICINE_CN.setFEAR("2");
					count++;
				} else if (count == 8) {
					testScore[8] = 2;
					testTile.setText(R.string.zhongyitizhi_test10);
					old_MEDICINE_CN.setWEIGHT("2");
					type1();
					count++;
				} else if (count == 9) {
					testScore[9] = 2;
					testTile.setText(R.string.zhongyitizhi_test11);
					old_MEDICINE_CN.setEYE("2");
					count++;
				} else if (count == 10) {
					testScore[10] = 2;
					testTile.setText(R.string.zhongyitizhi_test12);
					old_MEDICINE_CN.setFOOTHAND("2");
					count++;
				} else if (count == 11) {
					testScore[11] = 2;
					testTile.setText(R.string.zhongyitizhi_test13);
					old_MEDICINE_CN.setSTOMACH("2");
					count++;
				} else if (count == 12) {
					testScore[12] = 2;
					testTile.setText(R.string.zhongyitizhi_test14);
					button_select1.setText(R.string.type3_button1);
					button_select2.setText(R.string.type3_button2);
					button_select3.setText(R.string.type3_button3);
					button_select4.setText(R.string.type3_button4);
					button_select5.setText(R.string.type3_button5);
					old_MEDICINE_CN.setCOLD("2");
					count++;
				} else if (count == 13) {
					testScore[13] = 2;
					testTile.setText(R.string.zhongyitizhi_test15);
					old_MEDICINE_CN.setINFLUENZA("2");
					type1();
					count++;
				} else if (count == 14) {
					testScore[14] = 2;
					testTile.setText(R.string.zhongyitizhi_test16);
					old_MEDICINE_CN.setNASAL("2");
					count++;
				} else if (count == 15) {
					testScore[15] = 2;
					testTile.setText(R.string.zhongyitizhi_test17);
					button_select1.setText(R.string.type4_button1);
					button_select2.setText(R.string.type4_button2);
					button_select3.setText(R.string.type4_button3);
					button_select4.setText(R.string.type4_button4);
					button_select5.setText(R.string.type4_button5);
					old_MEDICINE_CN.setSNORE("2");
					count++;
				} else if (count == 16) {
					testScore[16] = 2;
					testTile.setText(R.string.zhongyitizhi_test18);
					old_MEDICINE_CN.setALLERGY("2");
					type1();
					count++;
				} else if (count == 17) {
					testScore[17] = 2;
					testTile.setText(R.string.zhongyitizhi_test19);
					old_MEDICINE_CN.setURTICARIA("2");
					count++;
				} else if (count == 18) {
					testScore[18] = 2;
					testTile.setText(R.string.zhongyitizhi_test20);
					old_MEDICINE_CN.setSKIN("2");
					count++;
				} else if (count == 19) {
					testScore[19] = 2;
					testTile.setText(R.string.zhongyitizhi_test21);
					old_MEDICINE_CN.setSCRATCH("2");
					count++;
				} else if (count == 20) {
					testScore[20] = 2;
					testTile.setText(R.string.zhongyitizhi_test22);
					old_MEDICINE_CN.setMOUTH("2");
					count++;
				} else if (count == 21) {
					testScore[21] = 2;
					testTile.setText(R.string.zhongyitizhi_test23);
					old_MEDICINE_CN.setARMS("2");
					count++;
				} else if (count == 22) {
					testScore[22] = 2;
					testTile.setText(R.string.zhongyitizhi_test24);
					old_MEDICINE_CN.setGREASY("2");
					count++;
				} else if (count == 23) {
					testScore[23] = 2;
					testTile.setText(R.string.zhongyitizhi_test25);
					old_MEDICINE_CN.setSPOT("2");
					count++;
				} else if (count == 24) {
					testScore[24] = 2;
					testTile.setText(R.string.zhongyitizhi_test26);
					old_MEDICINE_CN.setECZEMA("2");
					count++;
				} else if (count == 25) {
					testScore[25] = 2;
					testTile.setText(R.string.zhongyitizhi_test27);
					old_MEDICINE_CN.setTHIRSTY("2");
					count++;
				} else if (count == 26) {
					testScore[26] = 2;
					testTile.setText(R.string.zhongyitizhi_test28);
					button_select1.setText(R.string.type5_button1);
					button_select2.setText(R.string.type5_button2);
					button_select3.setText(R.string.type5_button3);
					button_select4.setText(R.string.type5_button4);
					button_select5.setText(R.string.type5_button5);
					old_MEDICINE_CN.setSMELL("2");
					count++;
				} else if (count == 27) {
					testScore[27] = 2;
					testTile.setText(R.string.zhongyitizhi_test29);
					old_MEDICINE_CN.setADBOMEN("2");
					type1();
					count++;
				} else if (count == 28) {
					testScore[28] = 2;
					testTile.setText(R.string.zhongyitizhi_test30);
					old_MEDICINE_CN.setCOOLFOOD("2");
					count++;
				} else if (count == 29) {
					testScore[29] = 2;
					testTile.setText(R.string.zhongyitizhi_test31);
					old_MEDICINE_CN.setDEFECATE("2");
					count++;
				} else if (count == 30) {
					testScore[30] = 2;
					testTile.setText(R.string.zhongyitizhi_test32);
					old_MEDICINE_CN.setDEFECATEDRY("2");
					count++;
				} else if (count == 31) {
					testScore[31] = 2;
					testTile.setText(R.string.zhongyitizhi_test33);
					old_MEDICINE_CN.setTONGUE("2");
					count++;
				} else if (count == 32) {
					old_MEDICINE_CN.setVEIN("2");
					testScore[32] = 2;
					getTestScore();
					count++;
				} else {

				}

			}
		});
		button_select3.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (count == 0) {
					testScore[0] = 3;
					testTile.setText(R.string.zhongyitizhi_test2);
					old_MEDICINE_CN.setENERGY("3");
					count++;
				} else if (count == 1) {
					testScore[1] = 3;
					testTile.setText(R.string.zhongyitizhi_test3);
					old_MEDICINE_CN.setTIRED("3");
					count++;
				} else if (count == 2) {
					testScore[2] = 3;
					testTile.setText(R.string.zhongyitizhi_test4);
					old_MEDICINE_CN.setBREATH("3");
					count++;
				} else if (count == 3) {
					testScore[3] = 3;
					testTile.setText(R.string.zhongyitizhi_test5);
					old_MEDICINE_CN.setVOICE("3");
					count++;
				} else if (count == 4) {
					testScore[4] = 3;
					testTile.setText(R.string.zhongyitizhi_test6);
					old_MEDICINE_CN.setEMOTION("3");
					count++;
				} else if (count == 5) {
					testScore[5] = 3;
					testTile.setText(R.string.zhongyitizhi_test7);
					old_MEDICINE_CN.setSPIRIT("3");
					count++;
				} else if (count == 6) {
					testScore[6] = 3;
					testTile.setText(R.string.zhongyitizhi_test8);
					old_MEDICINE_CN.setALONE("3");
					count++;
				} else if (count == 7) {
					testScore[7] = 3;
					testTile.setText(R.string.zhongyitizhi_test9);
					button_select1.setText(R.string.type2_button1);
					button_select2.setText(R.string.type2_button2);
					button_select3.setText(R.string.type2_button3);
					button_select4.setText(R.string.type2_button4);
					button_select5.setText(R.string.type2_button5);
					old_MEDICINE_CN.setFEAR("3");
					count++;
				} else if (count == 8) {
					testScore[8] = 3;
					testTile.setText(R.string.zhongyitizhi_test10);
					old_MEDICINE_CN.setWEIGHT("3");
					type1();
					count++;
				} else if (count == 9) {
					testScore[9] = 3;
					testTile.setText(R.string.zhongyitizhi_test11);
					old_MEDICINE_CN.setEYE("3");
					count++;
				} else if (count == 10) {
					testScore[10] = 3;
					testTile.setText(R.string.zhongyitizhi_test12);
					old_MEDICINE_CN.setFOOTHAND("3");
					count++;
				} else if (count == 11) {
					testScore[11] = 3;
					testTile.setText(R.string.zhongyitizhi_test13);
					old_MEDICINE_CN.setSTOMACH("3");
					count++;
				} else if (count == 12) {
					testScore[12] = 3;
					testTile.setText(R.string.zhongyitizhi_test14);
					button_select1.setText(R.string.type3_button1);
					button_select2.setText(R.string.type3_button2);
					button_select3.setText(R.string.type3_button3);
					button_select4.setText(R.string.type3_button4);
					button_select5.setText(R.string.type3_button5);
					old_MEDICINE_CN.setCOLD("3");
					count++;
				} else if (count == 13) {
					testScore[13] = 3;
					testTile.setText(R.string.zhongyitizhi_test15);
					old_MEDICINE_CN.setINFLUENZA("3");
					type1();
					count++;
				} else if (count == 14) {
					testScore[14] = 3;
					testTile.setText(R.string.zhongyitizhi_test16);
					old_MEDICINE_CN.setNASAL("3");
					count++;
				} else if (count == 15) {
					testScore[15] = 3;
					testTile.setText(R.string.zhongyitizhi_test17);
					button_select1.setText(R.string.type4_button1);
					button_select2.setText(R.string.type4_button2);
					button_select3.setText(R.string.type4_button3);
					button_select4.setText(R.string.type4_button4);
					button_select5.setText(R.string.type4_button5);
					old_MEDICINE_CN.setSNORE("3");
					count++;
				} else if (count == 16) {
					testScore[16] = 3;
					testTile.setText(R.string.zhongyitizhi_test18);
					old_MEDICINE_CN.setALLERGY("3");
					type1();
					count++;
				} else if (count == 17) {
					testScore[17] = 3;
					testTile.setText(R.string.zhongyitizhi_test19);
					old_MEDICINE_CN.setURTICARIA("3");
					count++;
				} else if (count == 18) {
					testScore[18] = 3;
					testTile.setText(R.string.zhongyitizhi_test20);
					old_MEDICINE_CN.setSKIN("3");
					count++;
				} else if (count == 19) {
					testScore[19] = 3;
					testTile.setText(R.string.zhongyitizhi_test21);
					old_MEDICINE_CN.setSCRATCH("3");
					count++;
				} else if (count == 20) {
					testScore[20] = 3;
					testTile.setText(R.string.zhongyitizhi_test22);
					old_MEDICINE_CN.setMOUTH("3");
					count++;
				} else if (count == 21) {
					testScore[21] = 3;
					testTile.setText(R.string.zhongyitizhi_test23);
					old_MEDICINE_CN.setARMS("3");
					count++;
				} else if (count == 22) {
					testScore[22] = 3;
					testTile.setText(R.string.zhongyitizhi_test24);
					old_MEDICINE_CN.setGREASY("3");
					count++;
				} else if (count == 23) {
					testScore[23] = 3;
					testTile.setText(R.string.zhongyitizhi_test25);
					old_MEDICINE_CN.setSPOT("3");
					count++;
				} else if (count == 24) {
					testScore[24] = 3;
					testTile.setText(R.string.zhongyitizhi_test26);
					old_MEDICINE_CN.setECZEMA("3");
					count++;
				} else if (count == 25) {
					testScore[25] = 3;
					testTile.setText(R.string.zhongyitizhi_test27);
					old_MEDICINE_CN.setTHIRSTY("3");
					count++;
				} else if (count == 26) {
					testScore[26] = 3;
					testTile.setText(R.string.zhongyitizhi_test28);
					button_select1.setText(R.string.type5_button1);
					button_select2.setText(R.string.type5_button2);
					button_select3.setText(R.string.type5_button3);
					button_select4.setText(R.string.type5_button4);
					button_select5.setText(R.string.type5_button5);
					old_MEDICINE_CN.setSMELL("3");
					count++;
				} else if (count == 27) {
					testScore[27] = 3;
					testTile.setText(R.string.zhongyitizhi_test29);
					old_MEDICINE_CN.setADBOMEN("3");
					type1();
					count++;
				} else if (count == 28) {
					testScore[28] = 3;
					testTile.setText(R.string.zhongyitizhi_test30);
					old_MEDICINE_CN.setCOOLFOOD("3");
					count++;
				} else if (count == 29) {
					testScore[29] = 3;
					testTile.setText(R.string.zhongyitizhi_test31);
					old_MEDICINE_CN.setDEFECATE("3");
					count++;
				} else if (count == 30) {
					testScore[30] = 3;
					testTile.setText(R.string.zhongyitizhi_test32);
					old_MEDICINE_CN.setDEFECATEDRY("3");
					count++;
				} else if (count == 31) {
					testScore[31] = 3;
					testTile.setText(R.string.zhongyitizhi_test33);
					old_MEDICINE_CN.setTONGUE("3");
					count++;
				} else if (count == 32) {
					old_MEDICINE_CN.setVEIN("3");
					testScore[32] = 3;
					getTestScore();
					count++;
				} else {

				}

			}
		});
		button_select4.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (count == 0) {
					testScore[0] = 4;
					testTile.setText(R.string.zhongyitizhi_test2);
					old_MEDICINE_CN.setENERGY("4");
					count++;
				} else if (count == 1) {
					testScore[1] = 4;
					testTile.setText(R.string.zhongyitizhi_test3);
					old_MEDICINE_CN.setTIRED("4");
					count++;
				} else if (count == 2) {
					testScore[2] = 4;
					testTile.setText(R.string.zhongyitizhi_test4);
					old_MEDICINE_CN.setBREATH("4");
					count++;
				} else if (count == 3) {
					testScore[3] = 4;
					testTile.setText(R.string.zhongyitizhi_test5);
					old_MEDICINE_CN.setVOICE("4");
					count++;
				} else if (count == 4) {
					testScore[4] = 4;
					testTile.setText(R.string.zhongyitizhi_test6);
					old_MEDICINE_CN.setEMOTION("4");
					count++;
				} else if (count == 5) {
					testScore[5] = 4;
					testTile.setText(R.string.zhongyitizhi_test7);
					old_MEDICINE_CN.setSPIRIT("4");
					count++;
				} else if (count == 6) {
					testScore[6] = 4;
					testTile.setText(R.string.zhongyitizhi_test8);
					old_MEDICINE_CN.setALONE("4");
					count++;
				} else if (count == 7) {
					testScore[7] = 4;
					testTile.setText(R.string.zhongyitizhi_test9);
					button_select1.setText(R.string.type2_button1);
					button_select2.setText(R.string.type2_button2);
					button_select3.setText(R.string.type2_button3);
					button_select4.setText(R.string.type2_button4);
					button_select5.setText(R.string.type2_button5);
					old_MEDICINE_CN.setFEAR("4");
					count++;
				} else if (count == 8) {
					testScore[8] = 4;
					testTile.setText(R.string.zhongyitizhi_test10);
					old_MEDICINE_CN.setWEIGHT("4");
					type1();
					count++;
				} else if (count == 9) {
					testScore[9] = 4;
					testTile.setText(R.string.zhongyitizhi_test11);
					old_MEDICINE_CN.setEYE("4");
					count++;
				} else if (count == 10) {
					testScore[10] = 4;
					testTile.setText(R.string.zhongyitizhi_test12);
					old_MEDICINE_CN.setFOOTHAND("4");
					count++;
				} else if (count == 11) {
					testScore[11] = 4;
					testTile.setText(R.string.zhongyitizhi_test13);
					old_MEDICINE_CN.setSTOMACH("4");
					count++;
				} else if (count == 12) {
					testScore[12] = 4;
					testTile.setText(R.string.zhongyitizhi_test14);
					button_select1.setText(R.string.type3_button1);
					button_select2.setText(R.string.type3_button2);
					button_select3.setText(R.string.type3_button3);
					button_select4.setText(R.string.type3_button4);
					button_select5.setText(R.string.type3_button5);
					old_MEDICINE_CN.setCOLD("4");
					count++;
				} else if (count == 13) {
					testScore[13] = 4;
					testTile.setText(R.string.zhongyitizhi_test15);
					old_MEDICINE_CN.setINFLUENZA("4");
					type1();
					count++;
				} else if (count == 14) {
					testScore[14] = 4;
					testTile.setText(R.string.zhongyitizhi_test16);
					old_MEDICINE_CN.setNASAL("4");
					count++;
				} else if (count == 15) {
					testScore[15] = 4;
					testTile.setText(R.string.zhongyitizhi_test17);
					button_select1.setText(R.string.type4_button1);
					button_select2.setText(R.string.type4_button2);
					button_select3.setText(R.string.type4_button3);
					button_select4.setText(R.string.type4_button4);
					button_select5.setText(R.string.type4_button5);
					old_MEDICINE_CN.setSNORE("4");
					count++;
				} else if (count == 16) {
					testScore[16] = 4;
					testTile.setText(R.string.zhongyitizhi_test18);
					old_MEDICINE_CN.setALLERGY("4");
					type1();
					count++;
				} else if (count == 17) {
					testScore[17] = 4;
					testTile.setText(R.string.zhongyitizhi_test19);
					old_MEDICINE_CN.setURTICARIA("4");
					count++;
				} else if (count == 18) {
					testScore[18] = 4;
					testTile.setText(R.string.zhongyitizhi_test20);
					old_MEDICINE_CN.setSKIN("4");
					count++;
				} else if (count == 19) {
					testScore[19] = 4;
					testTile.setText(R.string.zhongyitizhi_test21);
					old_MEDICINE_CN.setSCRATCH("4");
					count++;
				} else if (count == 20) {
					testScore[20] = 4;
					testTile.setText(R.string.zhongyitizhi_test22);
					old_MEDICINE_CN.setMOUTH("4");
					count++;
				} else if (count == 21) {
					testScore[21] = 4;
					testTile.setText(R.string.zhongyitizhi_test23);
					old_MEDICINE_CN.setARMS("4");
					count++;
				} else if (count == 22) {
					testScore[22] = 4;
					testTile.setText(R.string.zhongyitizhi_test24);
					old_MEDICINE_CN.setGREASY("4");
					count++;
				} else if (count == 23) {
					testScore[23] = 4;
					testTile.setText(R.string.zhongyitizhi_test25);
					old_MEDICINE_CN.setSPOT("4");
					count++;
				} else if (count == 24) {
					testScore[24] = 4;
					testTile.setText(R.string.zhongyitizhi_test26);
					old_MEDICINE_CN.setECZEMA("4");
					count++;
				} else if (count == 25) {
					testScore[25] = 4;
					testTile.setText(R.string.zhongyitizhi_test27);
					old_MEDICINE_CN.setTHIRSTY("4");
					count++;
				} else if (count == 26) {
					testScore[26] = 4;
					testTile.setText(R.string.zhongyitizhi_test28);
					button_select1.setText(R.string.type5_button1);
					button_select2.setText(R.string.type5_button2);
					button_select3.setText(R.string.type5_button3);
					button_select4.setText(R.string.type5_button4);
					button_select5.setText(R.string.type5_button5);
					old_MEDICINE_CN.setSMELL("4");
					count++;
				} else if (count == 27) {
					testScore[27] = 4;
					testTile.setText(R.string.zhongyitizhi_test29);
					old_MEDICINE_CN.setADBOMEN("4");
					type1();
					count++;
				} else if (count == 28) {
					testScore[28] = 4;
					testTile.setText(R.string.zhongyitizhi_test30);
					old_MEDICINE_CN.setCOOLFOOD("4");
					count++;
				} else if (count == 29) {
					testScore[29] = 4;
					testTile.setText(R.string.zhongyitizhi_test31);
					old_MEDICINE_CN.setDEFECATE("4");
					count++;
				} else if (count == 30) {
					testScore[30] = 4;
					testTile.setText(R.string.zhongyitizhi_test32);
					old_MEDICINE_CN.setDEFECATEDRY("4");
					count++;
				} else if (count == 31) {
					testScore[31] = 4;
					testTile.setText(R.string.zhongyitizhi_test33);
					old_MEDICINE_CN.setTONGUE("4");
					count++;
				} else if (count == 32) {
					old_MEDICINE_CN.setVEIN("4");
					testScore[32] = 4;
					getTestScore();
					count++;
				} else {

				}

			}
		});
		button_select5.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (count == 0) {
					testScore[0] = 5;
					testTile.setText(R.string.zhongyitizhi_test2);
					old_MEDICINE_CN.setENERGY("5");
					count++;
				} else if (count == 1) {
					testScore[1] = 5;
					testTile.setText(R.string.zhongyitizhi_test3);
					old_MEDICINE_CN.setTIRED("5");
					count++;
				} else if (count == 2) {
					testScore[2] = 5;
					testTile.setText(R.string.zhongyitizhi_test4);
					old_MEDICINE_CN.setBREATH("5");
					count++;
				} else if (count == 3) {
					testScore[3] = 5;
					testTile.setText(R.string.zhongyitizhi_test5);
					old_MEDICINE_CN.setVOICE("5");
					count++;
				} else if (count == 4) {
					testScore[4] = 5;
					testTile.setText(R.string.zhongyitizhi_test6);
					old_MEDICINE_CN.setEMOTION("5");
					count++;
				} else if (count == 5) {
					testScore[5] = 5;
					testTile.setText(R.string.zhongyitizhi_test7);
					old_MEDICINE_CN.setSPIRIT("5");
					count++;
				} else if (count == 6) {
					testScore[6] = 5;
					testTile.setText(R.string.zhongyitizhi_test8);
					old_MEDICINE_CN.setALONE("5");
					count++;
				} else if (count == 7) {
					testScore[7] = 5;
					testTile.setText(R.string.zhongyitizhi_test9);
					button_select1.setText(R.string.type2_button1);
					button_select2.setText(R.string.type2_button2);
					button_select3.setText(R.string.type2_button3);
					button_select4.setText(R.string.type2_button4);
					button_select5.setText(R.string.type2_button5);
					old_MEDICINE_CN.setFEAR("5");
					count++;
				} else if (count == 8) {
					testScore[8] = 5;
					testTile.setText(R.string.zhongyitizhi_test10);
					old_MEDICINE_CN.setWEIGHT("5");
					type1();
					count++;
				} else if (count == 9) {
					testScore[9] = 5;
					testTile.setText(R.string.zhongyitizhi_test11);
					old_MEDICINE_CN.setEYE("5");
					count++;
				} else if (count == 10) {
					testScore[10] = 5;
					testTile.setText(R.string.zhongyitizhi_test12);
					old_MEDICINE_CN.setFOOTHAND("5");
					count++;
				} else if (count == 11) {
					testScore[11] = 5;
					testTile.setText(R.string.zhongyitizhi_test13);
					old_MEDICINE_CN.setSTOMACH("5");
					count++;
				} else if (count == 12) {
					testScore[12] = 5;
					testTile.setText(R.string.zhongyitizhi_test14);
					button_select1.setText(R.string.type3_button1);
					button_select2.setText(R.string.type3_button2);
					button_select3.setText(R.string.type3_button3);
					button_select4.setText(R.string.type3_button4);
					button_select5.setText(R.string.type3_button5);
					old_MEDICINE_CN.setCOLD("5");
					count++;
				} else if (count == 13) {
					testScore[13] = 5;
					testTile.setText(R.string.zhongyitizhi_test15);
					old_MEDICINE_CN.setINFLUENZA("5");
					type1();
					count++;
				} else if (count == 14) {
					testScore[14] = 5;
					testTile.setText(R.string.zhongyitizhi_test16);
					old_MEDICINE_CN.setNASAL("5");
					count++;
				} else if (count == 15) {
					testScore[15] = 5;
					testTile.setText(R.string.zhongyitizhi_test17);
					button_select1.setText(R.string.type4_button1);
					button_select2.setText(R.string.type4_button2);
					button_select3.setText(R.string.type4_button3);
					button_select4.setText(R.string.type4_button4);
					button_select5.setText(R.string.type4_button5);
					old_MEDICINE_CN.setSNORE("5");
					count++;
				} else if (count == 16) {
					testScore[16] = 5;
					testTile.setText(R.string.zhongyitizhi_test18);
					old_MEDICINE_CN.setALLERGY("5");
					type1();
					count++;
				} else if (count == 17) {
					testScore[17] = 5;
					testTile.setText(R.string.zhongyitizhi_test19);
					old_MEDICINE_CN.setURTICARIA("5");
					count++;
				} else if (count == 18) {
					testScore[18] = 5;
					testTile.setText(R.string.zhongyitizhi_test20);
					old_MEDICINE_CN.setSKIN("5");
					count++;
				} else if (count == 19) {
					testScore[19] = 5;
					testTile.setText(R.string.zhongyitizhi_test21);
					old_MEDICINE_CN.setSCRATCH("5");
					count++;
				} else if (count == 20) {
					testScore[20] = 5;
					testTile.setText(R.string.zhongyitizhi_test22);
					old_MEDICINE_CN.setMOUTH("5");
					count++;
				} else if (count == 21) {
					testScore[21] = 5;
					testTile.setText(R.string.zhongyitizhi_test23);
					old_MEDICINE_CN.setARMS("5");
					count++;
				} else if (count == 22) {
					testScore[22] = 5;
					testTile.setText(R.string.zhongyitizhi_test24);
					old_MEDICINE_CN.setGREASY("5");
					count++;
				} else if (count == 23) {
					testScore[23] = 5;
					testTile.setText(R.string.zhongyitizhi_test25);
					old_MEDICINE_CN.setSPOT("5");
					count++;
				} else if (count == 24) {
					testScore[24] = 5;
					testTile.setText(R.string.zhongyitizhi_test26);
					old_MEDICINE_CN.setECZEMA("5");
					count++;
				} else if (count == 25) {
					testScore[25] = 5;
					testTile.setText(R.string.zhongyitizhi_test27);
					old_MEDICINE_CN.setTHIRSTY("5");
					count++;
				} else if (count == 26) {
					testScore[26] = 5;
					testTile.setText(R.string.zhongyitizhi_test28);
					button_select1.setText(R.string.type5_button1);
					button_select2.setText(R.string.type5_button2);
					button_select3.setText(R.string.type5_button3);
					button_select4.setText(R.string.type5_button4);
					button_select5.setText(R.string.type5_button5);
					old_MEDICINE_CN.setSMELL("5");
					count++;
				} else if (count == 27) {
					testScore[27] = 5;
					testTile.setText(R.string.zhongyitizhi_test29);
					old_MEDICINE_CN.setADBOMEN("5");
					type1();
					count++;
				} else if (count == 28) {
					testScore[28] = 5;
					testTile.setText(R.string.zhongyitizhi_test30);
					old_MEDICINE_CN.setCOOLFOOD("5");
					count++;
				} else if (count == 29) {
					testScore[29] = 5;
					testTile.setText(R.string.zhongyitizhi_test31);
					old_MEDICINE_CN.setDEFECATE("5");
					count++;
				} else if (count == 30) {
					testScore[30] = 5;
					testTile.setText(R.string.zhongyitizhi_test32);
					old_MEDICINE_CN.setDEFECATEDRY("5");
					count++;
				} else if (count == 31) {
					testScore[31] = 5;
					testTile.setText(R.string.zhongyitizhi_test33);
					old_MEDICINE_CN.setTONGUE("5");
					count++;
				} else if (count == 32) {
					old_MEDICINE_CN.setVEIN("5");
					testScore[32] = 5;
					getTestScore();
					count++;
				} else {

				}

			}
		});
		save_result.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				getTestScore();
				zybjzd();
				old_MEDICINE_RESULT.setIDCARD(IDCARD);
				archive_MEDI_PHYS_DIST.setIDCARD(IDCARD);
				old_MEDICINE_CN.setIDCARD(IDCARD);
				old_MEDICINE_CN.setARCHIVEID("");
				old_MEDICINE_CN.setRECORD_DATE(dateText.getDate());
				old_MEDICINE_CN.setIS_UPDATE("Y");
				if (fdDbManager.findAllByWhere(OLD_MEDICINE_CN.class, "IDCARD='" + IDCARD + "'").size() > 0) {
					old_MEDICINE_CN.setLAST_UPDATE_DATE(new Date());
					old_MEDICINE_CN.setLAST_UPDATE_BY(
							NovaApplication.getDoctorList().get(personText.getSelectedIndex()).getUSER_ID());
					old_MEDICINE_CN
							.setMODIFIED(NovaApplication.getDoctorList().get(personText.getSelectedIndex()).getUSER_ID());
					old_MEDICINE_CN.setUPDATEORG(NovaApplication.getUserInfo().getCREATEORG());
					old_MEDICINE_CN.setFOLLOWUP_DOCTOR(
							NovaApplication.getDoctorList().get(personText.getSelectedIndex()).getUSER_ID());
					fdDbManager.updata(old_MEDICINE_CN, "IDCARD='" + IDCARD + "'");
				} else {
					old_MEDICINE_CN.setLAST_UPDATE_DATE(new Date());
					old_MEDICINE_CN.setLAST_UPDATE_BY(
							NovaApplication.getDoctorList().get(personText.getSelectedIndex()).getUSER_ID());
					old_MEDICINE_CN.setFOLLOWUP_DOCTOR(
							NovaApplication.getDoctorList().get(personText.getSelectedIndex()).getUSER_ID());
					old_MEDICINE_CN.setCREATED_BY(NovaApplication.getUserInfo().getCREATED_BY());
					old_MEDICINE_CN.setCREATED_DATE(new Date());
					old_MEDICINE_CN.setCREATER(NovaApplication.getUserInfo().getCREATER());
					old_MEDICINE_CN.setCREATEORG(NovaApplication.getUserInfo().getCREATEORG());
					fdDbManager.save(old_MEDICINE_CN);
				}
				if (fdDbManager.findAllByWhere(OLD_MEDICINE_RESULT.class, "IDCARD='" + IDCARD + "'").size() > 0) {
					fdDbManager.updata(old_MEDICINE_RESULT, "IDCARD='" + IDCARD + "'");
				} else {
					fdDbManager.save(old_MEDICINE_RESULT);
				}
				if (fdDbManager.findAllByWhere(ARCHIVE_MEDI_PHYS_DIST.class, "IDCARD='" + IDCARD + "'").size() > 0) {
					fdDbManager.updata(archive_MEDI_PHYS_DIST, "IDCARD='" + IDCARD + "'");

				} else {
					fdDbManager.save(archive_MEDI_PHYS_DIST);

				}
				finish();
			}
		});

	}

	// 中医保健指导
	public void zybjzd() {
		String qixuzhi_zyzd = ((CheckBoxAdapter) myGridView_qixuzhi.getAdapter()).getCheckedSorts();
		String yangxuzhi_zyzd = ((CheckBoxAdapter) myGridView_yangxuzhi.getAdapter()).getCheckedSorts();
		String yinxuzhi_zyzd = ((CheckBoxAdapter) myGridView_yinxuzhi.getAdapter()).getCheckedSorts();
		String tanshizhi_zyzd = ((CheckBoxAdapter) myGridView_tanshizhi.getAdapter()).getCheckedSorts();
		String shirezhi_zyzd = ((CheckBoxAdapter) myGridView_shirezhi.getAdapter()).getCheckedSorts();
		String xueyuzhi_zyzd = ((CheckBoxAdapter) myGridView_xueyuzhi.getAdapter()).getCheckedSorts();
		String qiyuzhi_zyzd = ((CheckBoxAdapter) myGridView_qiyuzhi.getAdapter()).getCheckedSorts();
		String tebingzhi_zyzd = ((CheckBoxAdapter) myGridView_tebingzhi.getAdapter()).getCheckedSorts();
		String pinghezhi_zyzd = ((CheckBoxAdapter) myGridView_pinghezhi.getAdapter()).getCheckedSorts();

		old_MEDICINE_RESULT.setMILD_ADVISING(pinghezhi_zyzd);
		old_MEDICINE_RESULT.setFAINT_ADVISING(qixuzhi_zyzd);
		old_MEDICINE_RESULT.setYANG_ADVISING(yangxuzhi_zyzd);
		old_MEDICINE_RESULT.setYIN_ADVISING(yinxuzhi_zyzd);
		old_MEDICINE_RESULT.setPHLEGMDAMP_ADVISING(tanshizhi_zyzd);
		old_MEDICINE_RESULT.setMUGGY_ADVISING(shirezhi_zyzd);
		old_MEDICINE_RESULT.setBLOODSTASIS_ADVISING(xueyuzhi_zyzd);
		old_MEDICINE_RESULT.setQICONSTRAINT_ADVISING(qiyuzhi_zyzd);
		old_MEDICINE_RESULT.setCHARACTERISTIC_ADVISING(tebingzhi_zyzd);
		// old_MEDICINE_RESULT.setMILD_ADVISING_EX(pinghezhi_edit.getText().toString());
		// old_MEDICINE_RESULT.setFAINT_ADVISING_EX(qixuzhi_edit.getText().toString());
		// old_MEDICINE_RESULT.setYANG_ADVISING_EX(yangxuzhi_edit.getText().toString());
		// old_MEDICINE_RESULT.setYIN_ADVISING_EX(yinxuzhi_edit.getText().toString());
		// old_MEDICINE_RESULT.setPHLEGMDAMP_ADVISING_EX(tanshizhi_edit.getText().toString());
		// old_MEDICINE_RESULT.setMUGGY_ADVISING_EX(shirezhi_edit.getText().toString());
		// old_MEDICINE_RESULT.setBLOODSTASIS_ADVISING_EX(xueyuzhi_edit.getText().toString());
		// old_MEDICINE_RESULT.setQICONSTRAINT_ADVISING_EX(qiyuzhi_edit.getText().toString());
		// old_MEDICINE_RESULT.setCHARACTERISTIC_ADVISING_EX(tebingzhi_edit.getText().toString());

		old_MEDICINE_RESULT.setMILD_ADVISING_EX(checkBoxAdapter_pinghezhi.getOther());
		old_MEDICINE_RESULT.setFAINT_ADVISING_EX(checkBoxAdapter_qixuzhi.getOther());
		old_MEDICINE_RESULT.setYANG_ADVISING_EX(checkBoxAdapter_yangxuzhi.getOther());
		old_MEDICINE_RESULT.setYIN_ADVISING_EX(checkBoxAdapter_yinxuzhi.getOther());
		old_MEDICINE_RESULT.setPHLEGMDAMP_ADVISING_EX(checkBoxAdapter_tanshizhi.getOther());
		old_MEDICINE_RESULT.setMUGGY_ADVISING_EX(checkBoxAdapter_shirezhi.getOther());
		old_MEDICINE_RESULT.setBLOODSTASIS_ADVISING_EX(checkBoxAdapter_xueyuzhi.getOther());
		old_MEDICINE_RESULT.setQICONSTRAINT_ADVISING_EX(checkBoxAdapter_qiyuzhi.getOther());
		old_MEDICINE_RESULT.setCHARACTERISTIC_ADVISING_EX(checkBoxAdapter_tebingzhi.getOther());

	}

	public void getTestScore() {
		wentiLayout.setVisibility(View.GONE);
		resultLayout.setVisibility(View.VISIBLE);
		qixuzhi_score_string = testScore[1] + testScore[2] + testScore[3] + testScore[13];
		yangxuzhi_score_string = testScore[10] + testScore[11] + testScore[12] + testScore[28];
		yinxuzhi_score_string = testScore[9] + testScore[20] + testScore[25] + testScore[30];
		tanshizhi_score_string = testScore[8] + testScore[15] + testScore[27] + testScore[31];
		shirezhi_score_string = testScore[22] + testScore[24] + testScore[26] + testScore[29];
		xueyuzhi_score_string = testScore[18] + testScore[21] + testScore[23] + testScore[32];
		qiyuzhi_score_string = testScore[4] + testScore[5] + testScore[6] + testScore[7];
		tebingzhi_score_string = testScore[14] + testScore[16] + testScore[17] + testScore[19];
		pinghezhi_score_string = testScore[0] + (6-testScore[1]) + (6-testScore[3]) + (6-testScore[4]) + (6-testScore[12]);
		qixuzhi_score.setText(qixuzhi_score_string + "");
		yangxuzhi_score.setText(yangxuzhi_score_string + "");
		yinxuzhi_score.setText(yinxuzhi_score_string + "");
		tanshizhi_score.setText(tanshizhi_score_string + "");
		shirezhi_score.setText(shirezhi_score_string + "");
		xueyuzhi_score.setText(xueyuzhi_score_string + "");
		qiyuzhi_score.setText(qiyuzhi_score_string + "");
		tebingzhi_score.setText(tebingzhi_score_string + "");
		pinghezhi_score.setText(pinghezhi_score_string + "");
		// 得分存入数据库
		old_MEDICINE_RESULT.setMILD_SCORE(pinghezhi_score_string + "");
		old_MEDICINE_RESULT.setFAINT_SCORE(qixuzhi_score_string + "");
		old_MEDICINE_RESULT.setYANG_SCORE(yangxuzhi_score_string + "");
		old_MEDICINE_RESULT.setYIN_SCORE(yinxuzhi_score_string + "");
		old_MEDICINE_RESULT.setPHLEGMDAMP_SCORE(tanshizhi_score_string + "");
		old_MEDICINE_RESULT.setMUGGY_SCORE(shirezhi_score_string + "");
		old_MEDICINE_RESULT.setBLOODSTASIS_SCORE(xueyuzhi_score_string + "");
		old_MEDICINE_RESULT.setQICONSTRAINT_SCORE(qiyuzhi_score_string + "");
		old_MEDICINE_RESULT.setCHARACTERISTIC_SCORE(tebingzhi_score_string + "");
		if (qixuzhi_score_string >= 11) {
			result_qixuzhi_1.setChecked(true);
			old_MEDICINE_RESULT.setFAINT("DM100-24_1");
			archive_MEDI_PHYS_DIST.setFAINT("DM100-24_1");
		} else if (qixuzhi_score_string >= 9 && qixuzhi_score_string <= 10) {
			result_qixuzhi_2.setChecked(true);
			old_MEDICINE_RESULT.setFAINT("DM100-24_2");
			archive_MEDI_PHYS_DIST.setFAINT("DM100-24_2");
		} else {
			old_MEDICINE_RESULT.setFAINT("");
			archive_MEDI_PHYS_DIST.setFAINT("");
		}
		if (yangxuzhi_score_string >= 11) {
			result_yangxuzhi_1.setChecked(true);
			old_MEDICINE_RESULT.setYANG("DM100-24_1");
			archive_MEDI_PHYS_DIST.setYANG("DM100-24_1");
		} else if (yangxuzhi_score_string >= 9 && yangxuzhi_score_string <= 10) {
			result_yangxuzhi_2.setChecked(true);
			old_MEDICINE_RESULT.setYANG("DM100-24_2");
			archive_MEDI_PHYS_DIST.setYANG("DM100-24_2");
		} else {
			old_MEDICINE_RESULT.setYANG("");
			archive_MEDI_PHYS_DIST.setYANG("");
		}
		if (yinxuzhi_score_string >= 11) {
			result_yinxuzhi_1.setChecked(true);
			old_MEDICINE_RESULT.setYIN("DM100-24_1");
			archive_MEDI_PHYS_DIST.setYIN("DM100-24_1");
		} else if (yinxuzhi_score_string >= 9 && yinxuzhi_score_string <= 10) {
			result_yinxuzhi_2.setChecked(true);
			old_MEDICINE_RESULT.setYIN("DM100-24_2");
			archive_MEDI_PHYS_DIST.setYIN("DM100-24_2");
		} else {
			old_MEDICINE_RESULT.setYIN("");
			archive_MEDI_PHYS_DIST.setYIN("");
		}
		if (tanshizhi_score_string >= 11) {
			result_tanshizhi_1.setChecked(true);
			old_MEDICINE_RESULT.setPHLEGMDAMP("DM100-24_1");
			archive_MEDI_PHYS_DIST.setPHLEGMDAMP("DM100-24_1");
		} else if (tanshizhi_score_string >= 9 && tanshizhi_score_string <= 10) {
			result_tanshizhi_2.setChecked(true);
			old_MEDICINE_RESULT.setPHLEGMDAMP("DM100-24_2");
			archive_MEDI_PHYS_DIST.setPHLEGMDAMP("DM100-24_2");
		} else {
			old_MEDICINE_RESULT.setPHLEGMDAMP("");
			archive_MEDI_PHYS_DIST.setPHLEGMDAMP("");
		}
		if (shirezhi_score_string >= 11) {
			result_shirezhi_1.setChecked(true);
			old_MEDICINE_RESULT.setMUGGY("DM100-24_1");
			archive_MEDI_PHYS_DIST.setMUGGY("DM100-24_1");
		} else if (shirezhi_score_string >= 9 && shirezhi_score_string <= 10) {
			result_shirezhi_2.setChecked(true);
			old_MEDICINE_RESULT.setMUGGY("DM100-24_2");
			archive_MEDI_PHYS_DIST.setMUGGY("DM100-24_2");

		} else {
			old_MEDICINE_RESULT.setMUGGY("");
			archive_MEDI_PHYS_DIST.setMUGGY("");
		}
		if (xueyuzhi_score_string >= 11) {
			result_xueyuzhi_1.setChecked(true);
			old_MEDICINE_RESULT.setBLOODSTASIS("DM100-24_1");
			archive_MEDI_PHYS_DIST.setBLOODSTASIS("DM100-24_1");
		} else if (xueyuzhi_score_string >= 9 && xueyuzhi_score_string <= 10) {
			result_xueyuzhi_2.setChecked(true);
			old_MEDICINE_RESULT.setBLOODSTASIS("DM100-24_2");
			archive_MEDI_PHYS_DIST.setBLOODSTASIS("DM100-24_2");
		} else {
			old_MEDICINE_RESULT.setBLOODSTASIS("");
			archive_MEDI_PHYS_DIST.setBLOODSTASIS("");
		}
		if (qiyuzhi_score_string >= 11) {
			result_qiyuzhi_1.setChecked(true);
			archive_MEDI_PHYS_DIST.setQICONSTRAINT("DM100-24_1");
			old_MEDICINE_RESULT.setQICONSTRAINT("DM100-24_1");
		} else if (qiyuzhi_score_string >= 9 && qiyuzhi_score_string <= 10) {
			result_qiyuzhi_2.setChecked(true);
			old_MEDICINE_RESULT.setQICONSTRAINT("DM100-24_2");
			archive_MEDI_PHYS_DIST.setQICONSTRAINT("DM100-24_2");
		} else {
			old_MEDICINE_RESULT.setQICONSTRAINT("");
			archive_MEDI_PHYS_DIST.setQICONSTRAINT("");
		}
		if (tebingzhi_score_string >= 11) {
			result_tebingzhi_1.setChecked(true);
			old_MEDICINE_RESULT.setCHARACTERISTIC("DM100-24_1");
			archive_MEDI_PHYS_DIST.setCHARACTERISTIC("DM100-24_1");
		} else if (tebingzhi_score_string >= 9 && tebingzhi_score_string <= 10) {
			result_tebingzhi_2.setChecked(true);
			old_MEDICINE_RESULT.setCHARACTERISTIC("DM100-24_2");
			archive_MEDI_PHYS_DIST.setCHARACTERISTIC("DM100-24_2");
		} else {
			old_MEDICINE_RESULT.setCHARACTERISTIC("");
			archive_MEDI_PHYS_DIST.setCHARACTERISTIC("");
		}
		if (pinghezhi_score_string >= 17 && qixuzhi_score_string <= 8 && yangxuzhi_score_string <= 8
				&& yinxuzhi_score_string <= 8 && tanshizhi_score_string <= 8 && shirezhi_score_string <= 8
				&& xueyuzhi_score_string <= 8 && qiyuzhi_score_string <= 8 && tebingzhi_score_string <= 8) {
			result_pinghezhi_1.setChecked(true);
			old_MEDICINE_RESULT.setMILD("DM100-24_1");
			archive_MEDI_PHYS_DIST.setMILD("DM100-24_1");
		} else if (pinghezhi_score_string >= 17 && qixuzhi_score_string <= 10 && yangxuzhi_score_string <= 10
				&& yinxuzhi_score_string <= 10 && tanshizhi_score_string <= 10 && shirezhi_score_string <= 10
				&& xueyuzhi_score_string <= 10 && qiyuzhi_score_string <= 10 && tebingzhi_score_string <= 10) {
			result_pinghezhi_2.setChecked(true);
			old_MEDICINE_RESULT.setMILD("DM100-24_2");
			archive_MEDI_PHYS_DIST.setMILD("DM100-24_2");
		} else {
			old_MEDICINE_RESULT.setMILD("");
			archive_MEDI_PHYS_DIST.setMILD("");
		}
	}

	public void type1() {
		button_select1.setText(R.string.type1_button1);
		button_select2.setText(R.string.type1_button2);
		button_select3.setText(R.string.type1_button3);
		button_select4.setText(R.string.type1_button4);
		button_select5.setText(R.string.type1_button5);
	}
}
